package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.ManageService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author 李旭
 * @date 2022/1/7 10:35
 * @Description: 对外暴露 接口
 */
@RestController
@RequestMapping("/api/product")
@Api(tags = "商品对外暴露接口")
public class ProductApiController {

    @Autowired
    private ManageService manageService;

//    1、根据skuId查询sku_info  根据skuId查询sku_image  /inner：内部资源
    @GetMapping("/inner/getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable Long skuId){
        return manageService.getSkuInfo(skuId);
    }
    //2:查询实时价格   优化的时候 不要放进缓存中
    @GetMapping("/inner/getPrice/{skuId}")
    public BigDecimal getPrice(@PathVariable Long skuId){
        return manageService.getPrice(skuId);
    }
    //3、根据category3Id查询一二三级分类
    @GetMapping("/inner/getBaseCategoryView/{category3Id}")
    public BaseCategoryView getBaseCategoryView(@PathVariable Long category3Id){
        return manageService.getBaseCategoryView(category3Id);
    }

    //4、根据spuId查询spu_sale_attr_value(被选中项）  商品ID spu  库存ID
    @GetMapping("/inner/getSpuSaleAttrValue/{spuId}/{skuId}")
    public List<SpuSaleAttr> getSpuSaleAttrValue(
            @PathVariable Long spuId,
            @PathVariable Long skuId
    ){
        return manageService.getSpuSaleAttrValue(spuId,skuId);
    }
    //5、skuId与销售属性组合
    @GetMapping("/inner/spuValueIdsMap/{spuId}")
    public Map spuValueIdsMap(@PathVariable Long spuId){
        return manageService.spuValueIdsMap(spuId);
    }
    //6:查询所有分类视图集合
    @GetMapping("/inner/getBaseCategoryViewList")
    public List<BaseCategoryView> getBaseCategoryViewList(){
        return manageService.getBaseCategoryViewList();
    }

    //7:查询品牌
    @GetMapping("/inner/getBaseTrademarkById/{tmId}")
    public BaseTrademark getBaseTrademarkById(@PathVariable Long tmId){

        return manageService.getBaseTrademarkById(tmId);
    }
    //8: 根据skuId查询平台属性及属性值
    @GetMapping("/inner/getSkuAttrValueList/{skuId}")
    public List<SkuAttrValue> getSkuAttrValueList(@PathVariable Long skuId){

        return manageService.getSkuAttrValueList(skuId);
    }
}
